home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 005 / samplefont / samplefont.asm next >
Assembly Source File  |  1995-03-17  |  7KB  |  183 lines

  1. *
  2. *    DISCLAIMER:
  3. *
  4. *    This program is provided as a service to the programmer
  5. *    community to demonstrate one or more features of the Amiga
  6. *    personal computer.  These code samples may be freely used
  7. *    for commercial or noncommercial purposes.
  8. *     Commodore Electronics, Ltd ("Commodore") makes no
  9. *    warranties, either expressed or implied, with respect
  10. *    to the program described herein, its quality, performance,
  11. *    merchantability, or fitness for any particular purpose.
  12. *    This program is provided "as is" and the entire risk
  13. *    as to its quality and performance is with the user.
  14. *    Should the program prove defective following its
  15. *    purchase, the user (and not the creator of the program,
  16. *    Commodore, their distributors or their retailers)
  17. *    assumes the entire cost of all necessary damages.  In 
  18. *    no event will Commodore be liable for direct, indirect,
  19. *    incidental or consequential damages resulting from any
  20. *    defect in the program even if it has been advised of the 
  21. *    possibility of such damages.  Some laws do not allow
  22. *    the exclusion or limitation of implied warranties or
  23. *    liabilities for incidental or consequential damages,
  24. *    so the above limitation or exclusion may not apply.
  25. *
  26.  
  27. * samplefont.asm  
  28. *
  29. *
  30. *
  31. * A complete sample font.  To test this font, the following must be done:
  32. *
  33. * 1.  In the AmigaDOS SYS:fonts directory, install a file by the name of
  34. *     test.font, containing 264 bytes.   
  35. *    
  36. *    The first two bytes must contain the value hex 0f00, the
  37. *    identifier for a font header.
  38. *
  39. *    The next word (2 bytes), should contain the value 0001,
  40. *    which is the number of FontContents elements.  There is
  41. *    only going to be one font in the directory that this
  42. *    font description covers.
  43. *
  44. *    Follow this header material with the ascii value for
  45. *     'test/8';  the next 250 bytes should be set to zero. 
  46. *    This represents the pathname for AmigaDOS to follow
  47. *    from the directory SYS:fonts in order to reach this test font.
  48. *    'test' is the directory it should go to and '8' is the font
  49. *    file itself, as assembled and linked below.
  50. *
  51. *    The next two bytes (as one word) contain the font YSize, in
  52. *    this case 0008.  
  53. *    
  54. *    The next byte contains the font Flags, in this case 00.
  55. *
  56. *    The last byte contains the font characteristics, in this
  57. *    case hex 60, this says it is a disk-based font (bit 1 set)
  58. *    and the font has been removed (bit 7 set) saying that the
  59. *    font is not currently resident.
  60. *
  61. *    Summary (all in hex) of test.font file:
  62. *
  63. *    0f00 0001 test/8 ........ 0008 00   60
  64. *    word word 256-bytes...... word byte byte
  65. *    
  66. * 2.    Create a directory named 'test' in SYS:fonts.
  67. *
  68. *    Copy the file created by assembling and linking the test font
  69. *    below into a file named '8' in subdirectory SYS:fonts/test.
  70. *
  71. *    Use the font under the Notepad program or any other.  It
  72. *    defines ascii characters 'a' 'b' 'c' and 'd' only.  All
  73. *    other characters print an "unknown character", a rectangle.
  74. *
  75. *     author:  Rob Peck  12/1/85    
  76. *
  77. *    This code may be freely utilized to create programs for the Amiga
  78. *
  79. *------ Included Files -----------------------------------------------
  80.  
  81.         INCLUDE         "exec/types.i"
  82.         INCLUDE         "exec/nodes.i"
  83.         INCLUDE         "libraries/diskfont.i"
  84.  
  85.                 MOVEQ   #0,D0    ;provide an easy exit in case somebody
  86.                 ;tries to RUN this file instead of loading it.
  87.                 RTS
  88.                 DC.L    0               ; ln_Succ
  89.                 DC.L    0               ; ln_Pred
  90.                 DC.B    NT_FONT         ; ln_Type
  91.                 DC.B    0               ; ln_Pri
  92.                 DC.L    fontName        ; ln_Name
  93.                 DC.W    DFH_ID          ; FileID
  94.                 DC.W    1               ; Revision
  95.                 DC.L    0               ; Segment
  96. fontName:
  97.                 DS.B    MAXFONTNAME     ; Name
  98. font:
  99.                 DC.L    0               ; ln_Succ
  100.                 DC.L    0               ; ln_Pred
  101.                 DC.B    NT_FONT         ; ln_Type
  102.                 DC.B    0               ; ln_Pri
  103.                 DC.L    fontName        ; ln_Name
  104.                 DC.L    0               ; mn_ReplyPort
  105.                 DC.W    fontEnd-font    ; mn_Length
  106.                 DC.W    8               ; tf_YSize
  107.                 DC.B    0               ; tf_Style
  108.                 DC.B    FPF_DESIGNED+FPF_PROPORTIONAL   ; tf_Flags
  109.                 DC.W    14              ; tf_XSize
  110.                 DC.W    6               ; tf_Baseline
  111.  
  112. * baseline must be no greater a value than YSize-1, otherwise algorithmically
  113. * generated style (italic particularly) can corrupt system memory.
  114.  
  115.                 DC.W    1               ; tf_BoldSmear
  116.                 DC.W    0               ; tf_Accessors
  117.                 DC.B    97              ; tf_LoChar
  118.                 DC.B    100             ; tf_HiChar
  119.                 DC.L    fontData        ; tf_CharData
  120.                 DC.W    8               ; tf_Modulo, no of bytes to add to
  121.                     ; data pointer to go from one row of
  122.                     ; a character to the next row of it.
  123.                 DC.L    fontLoc         ; tf_CharLoc, bit position in the 
  124.                     ; font data at which the character 
  125.                     ; begins.
  126.                 DC.L    fontSpace       ; tf_CharSpace
  127.                 DC.L    fontKern        ; tf_CharKern
  128.  
  129. *******************************************************************
  130. * These are the suits-characters that this font data defines. 
  131. * ascii lower case a,b,c,d.  The font descriptor says that there
  132. * are 4 characters described here.  The fifth character in the
  133. * table is the character that is to be output when there is
  134. * no character in this character set that matches the ascii
  135. * value requested.
  136. *
  137. * 97            98            99        100           256
  138. *<            ><            ><        ><            ><            >
  139. *  @@@   @@@         @           @          @@@       @@@@@@@@@@@@
  140. * @@@@@ @@@@@      @@@@@        @@@        @@@@@      @@        @@
  141. *  @@@@@@@@@     @@@@@@@@@     @@@@@     @@  @  @@    @@        @@
  142. *   @@@@@@@     @@@@@@@@@@@   @@@@@@@   @@@@@@@@@@@   @@        @@
  143. *    @@@@@       @@@ @ @@@     @@@@@     @@  @  @@    @@        @@
  144. *     @@@            @          @@@          @        @@        @@
  145. *      @           @@@@@         @         @@@@@      @@@@@@@@@@@@
  146. *******************************************************************
  147. fontData: 
  148.             DC.W    $071C0,$08040,$070FF,$0F000
  149.             DC.W    $0FBE3,$0E0E0,$0F8C0,$03000
  150.             DC.W    $07FCF,$0F9F3,$026C0,$03000
  151.             DC.W    $03F9F,$0FFFF,$0FFC0,$03000
  152.             DC.W    $01F0E,$0B9F3,$026C0,$03000
  153.             DC.W    $00E00,$080E0,$020C0,$03000
  154.             DC.W    $00403,$0E040,$0F8FF,$0F000
  155.             DC.W    $00000,$00000,$00000,$00000
  156.             DC.W    $00000,$00000,$00000,$00000
  157.  
  158. * font data is bit-packed edge to edge to save space; thats what the
  159. * fontLoc is all about.
  160.  
  161. fontLoc:     
  162.             DC.L    $00000000B,$0000B000B,$000160007,$0001D000B
  163.         DC.L    $00028000C
  164.  
  165. * Each pair of words specifies how the characters are bit-packed.  For
  166. * example, the first character starts at bit position 0000, and is 000B
  167. * (11) bits wide.  The second character starts at bit position 000B and
  168. * is 000B bits wide, and so on.  Tells font handler how to unpack the 
  169. * bits from the array.
  170.  
  171. fontSpace:
  172.             DC.W    000012,000012,000008,000012,000013
  173.  
  174. * fontSpace array:  Use a space that is this-wide to contain this character
  175. *            when it is printed.
  176.  
  177. fontKern:
  178.             DC.W    000001,000001,000001,000001,000001
  179. fontEnd:
  180.         END
  181.